package com.zc

class CustomerController {

    def save() {
        def phoneNum=params.phoneNum
        def qqNum = params.qqNum
        if((!phoneNum) && (!qqNum)){
            flash.message="请输入您的电话或者QQ"
            redirect(url: "/#sign-up")
            return
        }
        def customer = new Customer(phoneNum: phoneNum,name: params.name,qqNum: params.qqNum)
        if(!customer.save(flush: true)){
            flash.message=customer.errors.allErrors.collect({g.message(error: it)}).join(",")
            redirect(url: "/#sign-up")
            return
        }
        flash.message="恭喜！您的信息已经提交成功，请等待我们的工作人员与您联系。"
        redirect(url: "/")
    }
}
